﻿using UnityEngine;
using System.Collections;

using HedgehogTeam.EasyTouch;

using System.Collections.Generic;

public interface InputListener
{
    bool CurrentGesture(Gesture current);
}

public class InputManager : Singleton<InputManager>
{

     List<InputListener> listeners;

    void Awake()
    {
        if(listeners == null)
        {
            listeners = new List<InputListener>();
        }
    }


    void Start () {
	
	}

    public void addListener(InputListener listener)
    {
        if(!listeners.Contains(listener))
        {
            listeners.Add(listener);
        } 
    }

	
	// Update is called once per frame
	void Update () {
        Gesture current = EasyTouch.current;
        //Debug.Log(current.type);
        if (current.type == EasyTouch.EvtType.On_SimpleTap)
        {
            Vector3 worldPos = current.GetTouchToWorldPoint(0);
            Debug.Log("世界坐标：" + worldPos.x + "===Y:" + worldPos.y);
        }

        if (current.type != EasyTouch.EvtType.None)
        {
            for (int i = 0; i < listeners.Count; i++)
            {
                listeners[i].CurrentGesture(current);
            }
        }
    }
}
